<template>
	<view class="cooperation">
			<span @click="selTag(item)" class="hot-item" v-for="item in tags">{{item.name}}({{item.contentCount}})</span>
	</view>
</template>

<script>
	import API from '../../common/api.js';
	export default {
		components:{
		},
		data() {
			return {
				height: uni.getSystemInfoSync().windowHeight,
				team:uni.getStorageSync('team')?JSON.parse(uni.getStorageSync('team')):{name:'团队',id:0},
				tags:[],
				flag:0
			}
		},
		onLoad(optinos){
			this.flag=optinos.flag
			this.getTags()
		},
		methods:{
			getTags(){
				API.tagsList({
					"limit": 10000,
					"managerId": this.team.id,
					"page": 0}).then(res=>{
					console.log(res,789)
					if(res.status==200){
						this.tags=res.data
					}else{
						uni.hideLoading()
						uni.showModal({
							title: '提示',
							content: '请求失败！',
							showCancel: false,
						});
					}
				})
			},
			selTag(item){
				if(this.flag){
					uni.setStorage({
						key: 'tagData',
						data: JSON.stringify({tagsId:item.id,tagsName:item.name}),
						success: function () {
							uni.navigateBack()
						}
					});
				}else{
					uni.navigateTo({
						url: '../index/knowledge?tagsId='+item.id+'&tagsName='+item.name
					});
				}
			},
		}
	}
</script>

<style>
	.cooperation{
		display: flex;
		flex-wrap: wrap;
		padding: 0 30upx;
	}
	.hot-item{
		padding:10upx 20upx;
		margin:20upx 20upx 0 0;
		line-height: 40upx;
		border-radius: 8upx;
		background-color: rgba(246, 246, 246, 1);
		text-align: center;
		color: rgba(50, 60, 72, 1);
		font-size: 26upx;
		font-family: PingFangSC-regular;
	}

</style>
